﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
///Editor 的摘要说明
/// </summary>
public class EditorEditShow:BaseEditShowField
{
	public EditorEditShow()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    public override IEnumerable<Control> GetThisTypeControl(ConfigColumns cCol, string value, bool isEdit)
    {
        CuteEditor.Editor ctrl = new CuteEditor.Editor();
        ctrl.EncodeHiddenValue = false;
        ctrl.URLType = CuteEditor.URLType.Absolute;
        ctrl.ID = cCol.ColumnName + "_EditShow";
        if (!string.IsNullOrEmpty(cCol.EditShowTextBoxWidth))
        {
            ctrl.Width = new System.Web.UI.WebControls.Unit(cCol.EditShowTextBoxWidth);
        }

        if (isEdit)
        {
            ctrl.Text = value.DecodeScript();
        }
        else
        {
            ctrl.Text = cCol.AddShowDefaultValue;
        }

        WebControl webctrl = ctrl.CreateCommandButton("InsertPager", "text.gif", "插入分页符");
        webctrl.Attributes["onclick"] = "CuteEditor_GetEditor(this).ExecCommand('PasteHTML',false,'<hr />')";
        //get the pos after the Italic int pos=Editor1.ToolControls.IndexOf("Italic")+1; 
        //add this custom button into the editor Editor1.InsertToolControl(pos,"MyButton",ctrl);
        int pos = ctrl.ToolControls.IndexOf("InsertParagraph") + 1;
        ctrl.InsertToolControl(pos, "InsertPager", webctrl);

        yield return ctrl;
    }

    private void SetMouseEvents(WebControl control)
    {
        control.Attributes["onmouseover"] = "CuteEditor_ButtonCommandOver(this)";
        control.Attributes["onmouseout"] = "CuteEditor_ButtonCommandOut(this)";
        control.Attributes["onmousedown"] = "CuteEditor_ButtonCommandDown(this)";
        control.Attributes["onmouseup"] = "CuteEditor_ButtonCommandUp(this)";
        control.Attributes["ondragstart"] = "CuteEditor_CancelEvent()";
    }
}
